package org.springcloud.wisdom.spring_01_canteen.login.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springcloud.wisdom.spring_01_canteen.login.entity.*;

@Mapper
public interface Clogindao {
    //查看老生
    @Select("SELECT * FROM wisdom.student WHERE sid=#{sid} AND adpass=#{adpass}")
    Student login(@Param("sid") String sid, @Param("adpass") String adpass);
    //查看商家
    @Select("SELECT * FROM wisdom.mall WHERE mname=#{mname} AND mpassword=#{mpassword} AND isdel='已同意'")
    Mall login1(@Param("mname") String mname, @Param("mpassword") String mpassword);
    //查看管理员
    @Select("SELECT * FROM wisdom.admin WHERE aname=#{aname} AND apassword=#{apassword}")
    Admin login2(@Param("aname") String aname, @Param("apassword") String apassword);
    //查看老师
    @Select("SELECT * FROM wisdom.teacher WHERE tid=#{tid} AND tpass=#{tpass}")
    Teacher login3(@Param("tid") String tid, @Param("tpass") String tpass);
    //查看新生
    @Select("SELECT * FROM wisdom.freshman WHERE adsno=#{adsno} AND adpass=#{adpass}")
    Freshman login4(@Param("adsno") String adsno, @Param("adpass") String adpass);
    //查看对应mid
    @Select("SELECT mphone FROM wisdom.mall WHERE mid=#{mid}")
    String selectBymid(@Param("mid") Integer mid);
    //商家注册的手机号
    @Insert("INSERT INTO wisdom.mall (mname,mpassword,mphone,canteen,mlicense,mrange) values" +
            "(#{mname},#{mpassword},#{mphone},#{canteen},#{mlicense},#{mrange})")
    int addMall(Mall mall);
    @Select("SELECT COUNT(*) FROM wisdom.mall WHERE mname = #{mname}")
    int countByMname(String mname);
}
